package com.example.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class LoginWebAppConfigurer extends WebMvcConfigurerAdapter {
	@Bean
    public HandlerInterceptor getLoginInterceptor(){
        return new LoginInterceptor();
    }

	@Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns 用于添加拦截规则, 这里假设拦截 /url 后面的全部链接
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(getLoginInterceptor()).addPathPatterns("/sys/**", "/ser/**").excludePathPatterns("/**/sysUserMgr/**", "/baiJiaYun/**", "/ser/weChat/**", "/ser/loginGuard/**");
        super.addInterceptors(registry);
    }

}
